// /////////////////////////////////////////////////////////////////////////////
//
// Name:            ScriptManager.h
// Author:          Michael Bartsch
//
// Desc:            The interface for the CScriptManager class.
//
// License:         Copyright (C) 2008-2009 Michael Bartsch
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the GNU General Public
//                  License as published by the Free Software Foundation,
//                  either version 3 of the License, or (at your option) any
//                  later version.
//
//                  This program is distributed in the hope that it will be
//                  useful, but WITHOUT ANY WARRANTY; without even the implied
//                  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
//                  PURPOSE. See the GNU General Public License for more
//                  details.
//
//                  You should have received a copy of the GNU General Public
//                  License along with this program. If not, see
//                  <http://www.gnu.org/licenses/>.
//
// /////////////////////////////////////////////////////////////////////////////

#if !defined(__C_SCRIPTMANAGER_H_INCLUDED__)
#define __C_SCRIPTMANAGER_H_INCLUDED__

// Include required header file(s).
#include <lua.hpp>

#include "./AIScript.h"
#include "./ColourScript.h"
#include "./CommunicatorScript.h"


// The CScriptManager class.
//! Main entry point to the embedded Lua scripting language.
class CScriptManager
{
public:

    //! Constructor
    CScriptManager();
    //! Deconstructor
    virtual ~CScriptManager();

    //! Returns an instance of the singleton of CScriptManager.
    static CScriptManager* Instance();

    ///! Initialises the Lua scripting language.
    void init();
    //! Clears the Lua scripting language.
    void clear();

    // Scripting functions.
    //! Executes the given string in Lua.
    //! @param string string to be executed
    void executeString(const char* string);
    //! Executes the given file.
    //! @param filename filename of the file to be executed
    void executeFile(const char* filename);

    // Set Functions.
    //! Function to register Lua output.
    //!
    //! lua_altPrint uses this function to print the Lua output
    //! to the Script Manager and not the terminal.
    //!
    //! @see lua_altPrint
    void setOutput(std::string output);

    // Get Functions.
    //! Gets the Lua output given to the Script Manager.
    std::string getOutput();


private:

    // CColourAnalyser singleton.
	static CScriptManager *pInstance;

	// Lua
    lua_State *luaState;

    // Misc.
    std::string outputString;
};

#endif
